import React, { Dispatch } from 'react';
import { ToAssetControllerAPI } from '../common/type';
import { FormInstance } from 'antd';

interface ToAssetControllerTableTypes {
  dataSource: Record<string, any>[]; //表格数据
  loading: boolean; // 加载
  mapList: Record<string, any>;
  materielForm: any; // 选中的材料信息表单
  pagination: Record<string, any>; //分页参数
  otherParams: Record<string, any>; //当前请求参数
  searchList: ToAssetControllerAPI.ISearchList;
  reloadTableData: () => void; // 重置
  [key: string]: any;
}

/**
 * Context 默认值类型
 */
type ManageContextTypes = {
  prefixCls: string;
  styleFixCls: string;
  contractForm: FormInstance | any;
  curRes: Record<string, any>; // 权限
  toAssetControllerDispatch: Dispatch<any>; // 派发
  materielList: Record<string, any>[]; // 选中的材料列表
  contractList: Record<string, any>[]; // 选中的合同列表
  addMatrielList: any;
};

/**
 * useContext
 * @rightTableProps 公共表格所需参数
 * @curRes 权限
 * @toAssetControllerDispatch reduce 派发器
 */
const INIT_TOASSETCONTROLLERMANAGE_CONTEXT: ManageContextTypes = {
  prefixCls: 'apply-update',
  styleFixCls: 'contract-styfixcls-',
  contractForm: {},
  contractList: [],
  materielList: [],
  addMatrielList: [],
  curRes: {},
  toAssetControllerDispatch: () => {},
};

const ToAssetControllerContext = React.createContext(INIT_TOASSETCONTROLLERMANAGE_CONTEXT);

export { ToAssetControllerContext };
